package com.xuelangyun;

import com.xuelangyun.service.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @Version 1.0
 * @Author:xinyan
 * @Date:2022/4/7
 * @Content:
 */
public class Starter {
  public static void main(String[] args) {
    //得到Spring的上下文环境，ApplicationContext接口代表Spring IOC容器，并负责实例化，配置和组装Bean

      ApplicationContext ac = new ClassPathXmlApplicationContext("spring.xml");
    //得到需要被实例化对象，getBean(id) id 代表spring.xml配置中bean中id属性值
      UserService userService = (UserService) ac.getBean("userService");
      userService.test();

  }
}
 